﻿<script type="text/javascript">
    var toolbar_qita = [{
        text: '新增材料去向',
        iconCls: 'icon-add',
        handler: function () {
            $("#qita-edit").dialog('open');
            $("#info-qita-mingcheng").textbox('setValue', '');
            $("#qitaID").val('');
        }
    }, '-', {
        text: '修改',
        iconCls: 'icon-edit',
        handler: function () {
            var curRow = $("#xinxi_qita").datagrid('getSelected');
            if (curRow) {
                $("#qita-edit").dialog('open');
                $("#info-qita-mingcheng").textbox('setValue', curRow.biaoduanmingcheng);
                $("#qitaID").val(curRow.id);
            }
            else {
                alert("请选择要修改的其他去向信息。");
            }
        }
    }, '-', {
        text: '删除',
        iconCls: 'icon-remove',
        handler: function () {
            $("#qita-dlg").dialog('open');
        }
    }];

    function Delqita() {
        var curRow = $("#xinxi_qita").datagrid('getSelected');
        if (curRow) {
            $.post('handler/xinxi_qita.ashx', { requestType: "3", qitaID: curRow.id, qitaLeiXing: "其他", uid: window.uid, kid: window.kid }, function (data, status) {
                if (data == "OK") {
                    $("#qita-dlg").dialog('close');
                    $("#xinxi_qita").datagrid('load');
                    return;
                }
                if (data == "Failed") {
                    alert("删除其他去向信息失败，请重试");
                    $("#qita-dlg").dialog('close');
                    return;
                }
                alert(data);
                $("#qita-dlg").dialog('close');
            });
        }
        else {
            alert("请选择要删除的其他去向信息。");
        }
    }

    function submitqitaForm() {
        var qitamingcheng = $("#info-qita-mingcheng").textbox('getText');
        var qitaid = $("#qitaID").val();
        if (qitamingcheng) {
            $.post('handler/xinxi_qita.ashx', { uid: window.uid, kid: window.kid, requestType: '2', qitaLeiXing: '其他', qitaID: qitaid, qitamingcheng: qitamingcheng, zhandian: $("#info-qita-zhandian").combobox('getText') }, function (data, status) {
                if (data == "OK") {
                    $("#qita-edit").dialog('close');
                    $("#xinxi_qita").datagrid('load');
                    return;
                }
                if (data == "Failed") {
                    alert("保存其他去向信息失败，请重试");
                    return;
                }
                alert(data);
            });
        }
        else {
            alert("信息不完整，请检查后重试。");
        }

    }
    function clearqitaForm() {
        $("#qita-edit").dialog('close');
    }

    $("#chaxun-qita").click(function () {
        $("#xinxi_qita").datagrid('load', { requestType: '1', qitaLeiXing: '其他', uid: window.uid, kid: window.kid, zhandian: $("#zhandian-qita").combobox('getText') });
    });

    $.parser.onComplete = function () {

        $("#info-qita-zhandian").combobox({
            url: 'json/zhandian.json',
            method: 'get',
            valueField: 'zhandian',
            textField: 'zhandian',
            panelWidth: 200,
            panelHeight: 'auto',
            editable: false,
            loadFilter: function (data) {
                var returnData = [];
                for (var i = 0; i < data.length; i++) {
                    if (data[i].zhandian != "—全部—") {
                        returnData.push(data[i]);
                    }
                }
                return returnData;
            }
        });

        $("#zhandian-qita").combobox({
            url: 'json/zhandian.json',
            method: 'get',
            valueField: 'zhandian',
            textField: 'zhandian',
            panelWidth: 200,
            panelHeight: 'auto',
            editable: false,
            onLoadSuccess: function () {
                $("#xinxi_qita").datagrid({
                    url: 'handler/xinxi_qita.ashx', method: 'post', queryParams: { requestType: '1', qitaLeiXing: '其他', uid: window.uid, kid: window.kid, zhandian: $("#zhandian-qita").combobox('getText') }, height: document.body.scrollHeight - 90, onSelect: function (index, row) {
                        $("#qitaID").val(row.id);
                    }
                });
            }
        });

     
    }

</script>

<div class="easyui-panel" data-options="height:90,border:false" title="数据检索" style="border-top-width: 0px;border-bottom-width: 1px; padding: 15px;width:100%">
    <table style="font-size: 12px;">
        <tr>
            <td>
                站点：
            </td>
            <td>
                <input name="zhandian-qita" id="zhandian-qita" style="width: 175px;" />
            </td>
            <td>
                <a id="chaxun-qita" class="easyui-linkbutton" data-options="iconCls:'icon-search'"
                   style="width: 60px; margin-left: 20px;">查询</a>
            </td>
        </tr>
    </table>
</div>

<table id="xinxi_qita" style="width: 100%" title="材料使用部位——其他" class="easyui-datagrid" data-options="border: false, singleSelect: true, collapsible: false, striped: true, toolbar: toolbar_qita">
    <thead>
        <tr>
            <th data-options="field:'biaoduanmingcheng',width:200">
                材料去向名称
            </th>
            <th data-options="field:'id',hidden:true">
                编号
            </th>
        </tr>
    </thead>
</table>
<div id="qita-edit" class="easyui-dialog" title="材料去向信息编辑" data-options="modal:true,closed:true,iconCls:'icon-edit',draggable:false,collapsible:false,minimizable:false,maximizable:false,resizable:false"
     style="width: 500px; height: 220px; padding: 10px;">
    <div style="width: 350px; margin: 0 auto;">
        <table cellpadding="5" style="font-size: 13px; margin: 0 auto; padding-top: 20px">
            <tr>
                <td>
                    站点:
                </td>
                <td>
                    <input class="easyui-textbox" type="text" id="info-qita-zhandian" name="info-qita-zhandian"
                           data-options="width:200"></input>
                </td>
            </tr>
            <tr>
                <td>
                    材料去向名称:
                </td>
                <td>
                    <input class="easyui-textbox" type="text" id="info-qita-mingcheng" name="info-qita-mingcheng"
                           data-options="width:200"></input>
                </td>
            </tr>
        </table>
        <input type="hidden" name="qitaID" id="qitaID" value="" />
        <div style="text-align: center; padding: 5px">
            <a href="javascript:void(0)" class="easyui-linkbutton" style="width: 75px" onclick="submitqitaForm()"
               data-options="iconCls:'icon-ok'">保存</a> <a href="javascript:void(0)" class="easyui-linkbutton"
                                                          style="width: 75px" onclick="clearqitaForm()" data-options="iconCls:'icon-cancel'">
                关闭
            </a>
        </div>
    </div>
</div>
<div id="qita-dlg" class="easyui-dialog" title="删除确认" style="width: 300px; height: 150px; padding: 10px" data-options="iconCls: 'icon-help',buttons: '#qita-dlg-buttons',modal:true,closed:true">
    确定要删除该去向信息吗？
</div>
<div id="qita-dlg-buttons">
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:Delqita();">
        确定
    </a> <a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:$('#qita-dlg').dialog('close')">
        取消
    </a>
</div>
